'
该场景为随机音频播放组件
'

extends AudioStreamPlayer

@export var streams: Array[AudioStream]#音频数组，存储要播放的音频
@export var randomize_pitch: bool = true#是否随机音频音调大小的开关
@export var min_pitch = .9#最小音调
@export var max_pitch = 1.1#最大音调

#从音频数组中随机播放一个音频
func play_random() -> void:
	if streams.is_empty():
		return
	
	if randomize_pitch:
		self.pitch_scale = randf_range(min_pitch, max_pitch)
	else:
		self.pitch_scale = 1
	self.stream = streams.pick_random()
	self.play()
	pass
